﻿package mortal.game.view.nationalDayAct
{
    import com.mui.controls.*;
    import fl.data.*;
    import flash.events.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.view.common.*;
    import mortal.mvc.core.*;

    public class nationalDayActCategorySpr extends GSprite
    {
        private var _tagList:GTileList;
        private var _selectIndex:int;

        public function nationalDayActCategorySpr()
        {
            return;
        }// end function

        public function switchTag(param1:int) : void
        {
            this._selectIndex = param1;
            Dispatcher.dispatchEvent(new DataEvent(EventName.NationalDayActSwitchPanel, this._selectIndex));
            return;
        }// end function

        private function onItemChange(event:Event) : void
        {
            var _loc_2:* = nationalDayActConst.tagArr[int(this._tagList.selectedIndex)]["tagIndex"];
            this.switchTag(_loc_2);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.pushUIToDisposeVec(UIFactory.bg(0, 4, 194, 550, this));
            this._tagList = UIFactory.tileList(2, 6, 200, 542, this);
            this._tagList.rowHeight = 68;
            this._tagList.columnWidth = 190;
            this._tagList.horizontalGap = 0;
            this._tagList.verticalGap = -4;
            this._tagList.setStyle("cellRenderer", nationalDayActCategoryCellRender);
            this._tagList.dataProvider = this.getTagListDataProvider();
            this._tagList.drawNow();
            this._tagList.configEventListener(Event.CHANGE, this.onItemChange);
            return;
        }// end function

        private function getTagListDataProvider() : DataProvider
        {
            var _loc_3:int = 0;
            var _loc_4:nationalDayActCategoryData = null;
            var _loc_1:* = new DataProvider();
            var _loc_2:int = 0;
            while (_loc_2 < nationalDayActConst.tagArr.length)
            {
                
                _loc_3 = nationalDayActConst.tagArr[_loc_2]["tagIndex"];
                _loc_4 = nationalDayActUtil.getCategoryData(_loc_3);
                _loc_1.addItem(_loc_4);
                _loc_2++;
            }
            return _loc_1;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._tagList.dispose(param1);
            this._tagList = null;
            super.disposeImpl(param1);
            return;
        }// end function

    }
}
